import audioConf from '../../confs/audio-conf.js'
import gameView from '../game/view'

class AudioManager{
  constructor() {
    this.init()
  }

  init(){
    for(let key in audioConf.audioSources){
      this[key] = wx.createInnerAudioContext()
      // 指定source 根据上下文加载音频, 里面值就是音频路径
      this[key].src = audioConf.audioSources[key]
    }

    this.shrink_end.loop = true
    this.shrink.onEnded(() => {
      if(gameView.gamePage.bottle.status == 'shrink'){
        this.shrink_end.play()
      }
      
    })
  }
}

// 单例 全局只注册一次
export default new AudioManager()